|
|
|
|
|
|
|
In fact, you can use the different events to have your application respond to the drag-and-drop request based on the mouse button or key (shift, alt, ctrl) that was hit with the mouse button. Also, if you want to analyze or modify the data before it's dropped into the control, or dragged from it, you would need to use the manual OLE drag-and-drop operations. This gives you full control of the drag-and-drop process. If you look back at the simple text box/WordPad example, you will notice that the data is moved from the text box into WordPad. If you want to copy the data, you can use the built-in Windows copy feature by holding the Ctrl key when dragging the data. However, this will only work when both objects involved are supported and using the automatic process. |
|
|
|
|
|
|
|
|
Because data can be dragged and dropped into many different controls or applications, implementing OLE drag and drop can range in difficulty from straightforward to fairly complex. The easiest method, of course, is dragging and dropping between two automatic objects. |
|
|
|
|
|
|
|
|
A manual OLE drag-and-drop operation starts when the user selects and then drags data from an OLE drag source (such as a TextBox control). When this happens, the OLEStarDrag event is triggered, and you can choose to either store the data or simply specify the formats that the source control will support. You also need to specify if copying or moving the data, or both, will be enabled by the source control. |
|
|
|
|
|
|
|
|
As the data is dragged over a control, the OLEDragOver event is triggered and you would then add code to the event to either refuse the data or accept it while specifying if the drag is a copy or a move. The default is generally set to move; however, you can change the default to copy if you want. When the user drops the data, the OLEGiveFeedback event is triggered to give the user feedback on what action has been taken when the data was dropped (that is, the mouse pointer changes to indicate a copy, move, or no drop action). Figure 15.1 shows the three different mouse pointer icons that come with Visual Basic. |
|
|
|
|
|
|
|
|
Figure 15.1.
The default mouse icons used for the OLE drag-and-drop operations. |
|
|
|
|
|